#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = 200005;
int n,x,y;
int a[maxn],b[maxn];

int main(){
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=x;i++){
		if(y<=0 || a[i]>y)break;
		a[i]=y;
	}
	if(x>0 && y>0)	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=max(ans,b[i]-a[i]);
	} 
	cout<<ans<<endl;
}
